package com.xuecheng.teaching.controller;

import com.xuecheng.teaching.model.dto.WorkRecOverallDTO;
import com.xuecheng.teaching.model.dto.WorkRecordDTO;
import com.xuecheng.teaching.model.vo.WorkRecordPageListVO;
import com.xuecheng.teaching.service.WorkRecordService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/work-record")
public class WorkRecordController {

    @Resource
    private WorkRecordService workRecordService;

    @PostMapping("/list")
    public WorkRecordPageListVO getWorkRecordList(
            @RequestParam(defaultValue = "1") Integer pageNo,
            @RequestParam(defaultValue = "10") Integer pageSize,
            @RequestParam(required = false) String workTitle) {
        return workRecordService.getWorkRecordList(pageNo, pageSize, workTitle);
    }

    /**
     * 提交作业
     */
    @PostMapping("/submit")
    public Boolean submitWork(@RequestBody WorkRecordDTO workRecordDTO) {
        workRecordDTO.setUsername("stu1");
        return workRecordService.submitWork(workRecordDTO);
    }

    /**
     * 获取作业状态
     */
    @GetMapping("/status")
    public WorkRecordDTO getWorkStatus(@RequestParam Long workId,
                                       @RequestParam Long coursePubId) {

        return workRecordService.getWorkStatus(workId, coursePubId, "stu1");
    }
    /**
     * 批改作业
     */
    @PutMapping("/correction")
    public Boolean correctWork(@RequestBody WorkRecordDTO workRecordDTO) {
        return workRecordService.correctWork(workRecordDTO);
    }

    /**
     * 查询课程作业提交记录
     */
//    @GetMapping("/list")
//    public List<WorkRecordDTO> queryWorkRecords(@PathVariable Long coursePubId) {
//        return workRecordService.queryWorkRecords(coursePubId);
//    }

    /**
     * 查询待批阅作业数量
     */
    @GetMapping("/tobe-reviewed/{coursePubId}")
    public Integer queryToBeReviewedCount(@PathVariable Long coursePubId) {
        return workRecordService.queryToBeReviewedCount(coursePubId);
    }
    @GetMapping("/read-over-all/{courseWorkId}")
    public WorkRecOverallDTO getWorkRecordReadOverAll(@PathVariable Long courseWorkId) {
        return workRecordService.getWorkRecordReadOverAll(courseWorkId);
    }
}